package com.zq.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zq.comm.Const;
import com.zq.dao.EvaDao;
import com.zq.page.Page;
import com.zq.pojo.Eva;
import com.zq.service.EvaService;
@Service("EvaService")
public class EvaServiceImpl implements EvaService {
	@Autowired
	private EvaDao evaDao;
	
	@Override
	public String add(Eva eva) {
		// TODO Auto-generated method stub
			String msg = Const.ERROR;
			try {
				evaDao.add(eva);
				msg = Const.SUCCESS;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				return msg;
	}

	@Override
	public String delete(Eva eva) {
		String msg = Const.ERROR;
		try {
			evaDao.delete(eva);
			msg = Const.SUCCESS;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}

	@Override
	public String update(Eva eva) {
		String msg = Const.ERROR;
		try {
			evaDao.update(eva);
			msg = Const.SUCCESS;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}

	@Override
	public Eva findById(int eid) {
		// TODO Auto-generated method stub
				Eva eva = null;
				try {
					eva = evaDao.findById(eid);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return eva;
	}

	@Override
	public List<Eva> findAllEvas() {
		List<Eva> evas = new ArrayList<Eva>();;
		try {
			evas = evaDao.findAll();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return evas;
	}

	@Override
	public List<Eva> findAll(int pageNo) {
		List<Eva> evas = new ArrayList<Eva>();
		try {
			evas = evaDao.findAll(pageNo);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return evas;
	}

	@Override
	public Page<Eva> getPage(int pageNo) {
		Page<Eva> page = null;
		try {
			page = evaDao.getPage(pageNo);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return page;
	}


	@Override
	public List<Eva> getManyThings() {
		List<Eva> e = new ArrayList<>();
		try {
			e = evaDao.getManyThings();
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return e;
	}

	@Override
	public int getTotalNum()  {
		int num = 0;
		try {
			num = evaDao.getTotalNum();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

}
